Skip to content

ref: Reorganise into Swift Package Manager layout#2

Merged
cuiko merged 1 commit into
mainfrom
refactor/spm-layout
May 22, 2026
Merged

ref: Reorganise into Swift Package Manager layout#2
cuiko merged 1 commit into
mainfrom
refactor/spm-layout

Conversation

@cuiko

@cuiko cuiko commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split TermIMS.swift (2,185 lines) into 12 focused files under Sources/TermIMS/, modelled on the neighbouring notchnotes project layout.
  • Switch the build from a direct swiftc invocation to Swift Package Manager (swift build -c release), wrapped by Scripts/package-app.sh which assembles the .app bundle, generates AppIcon.icns from Resources/AppIcon.png, and ad-hoc signs the result.
  • Keep the existing make build / install / run / dist interface so release docs and CLAUDE.md instructions still apply unchanged.
Package.swift
Sources/TermIMS/
  main.swift
  AppDelegate.swift
  InputSource.swift
  Models.swift
  Log.swift
  RuleStore.swift
  TitleHeuristics.swift
  TerminalAdapters.swift
  IndicatorPanel.swift
  FocusMonitor.swift
  SettingsWindowController.swift
  PermissionWindowController.swift
Resources/AppIcon.png
Scripts/package-app.sh
Info.plist
Makefile

No behavioural changes — the bundle ID, Info.plist, AX permission flow, rules schema, and release pipeline are all untouched. fileprivate helpers that crossed the old single-file boundary (String heuristics, FocusMonitor.ttyDev(forName:), subprocess utilities shared by kitty/wezterm) were widened to internal so the new layout compiles cleanly.

Test plan

  • make build produces a clean, code-signed build/TermIMS.app
  • make install && make run launches the menu bar app, status icon appears, Settings opens
  • Existing rules (App Rules + Terminal Rules with the note field) round-trip from UserDefaults — verified by launching against an existing v1.2.0 install's stored state
  • No compiler warnings on release build
  • AppIcon renders in /Applications and the menu bar — generated from Resources/AppIcon.png at build time
  • make dist produces a working DMG (run before tagging next release)

@cuiko cuiko mentioned this pull request May 22, 2026
2 tasks
The single 2,185-line TermIMS.swift was getting unwieldy — navigating
between, say, the matching logic and the table view code meant
scrolling past several unrelated subsystems. Reorganise on Swift Package
Manager along the same shape as the neighbouring notchnotes project:

  Package.swift                # SPM manifest, executable target
  Sources/TermIMS/             # one file per logical concern
    main.swift                 # NSApplication boot
    AppDelegate.swift          # status menu + lifecycle
    InputSource.swift          # TIS wrappers
    Models.swift               # Rule / TerminalRule / enums + notifs
    Log.swift                  # append-only debug log
    RuleStore.swift            # UserDefaults-backed store
    TitleHeuristics.swift      # String pattern + cwd predicates
    TerminalAdapters.swift     # protocol + 5 adapters + subprocess utils
    IndicatorPanel.swift       # NSPanel overlay
    FocusMonitor.swift         # AX observers + match orchestration
    SettingsWindowController.swift   # Settings UI + drag handle views
    PermissionWindowController.swift # onboarding modal
  Resources/AppIcon.png        # source for the generated icns
  Scripts/package-app.sh       # swift build + bundle assembly + sign
  Makefile                     # thin wrapper, same target names as before
  Info.plist                   # unchanged, copied into the .app

The package script generates AppIcon.icns from AppIcon.png on every
build (matching notchnotes), so the icns no longer lives in the repo.
The Makefile keeps its public surface (\`make build/install/run/dist\`)
so existing release docs and CLAUDE.md instructions still apply.

\`fileprivate\` helpers that crossed the old file split — String
extensions, \`FocusMonitor.ttyDev(forName:)\`, the subprocess utilities
shared by kitty/wezterm adapters — were widened to internal so the new
file layout compiles. Nothing changes in behaviour.

Update README and CLAUDE.md to reflect the new layout and drop the
"single Swift file compiled with swiftc" language.
@cuiko
cuiko force-pushed the refactor/spm-layout branch from 56f65db to 1db47d8 Compare May 22, 2026 18:20
@cuiko
cuiko merged commit e9fafb5 into main May 22, 2026
1 check passed
@cuiko cuiko mentioned this pull request May 22, 2026
2 tasks
@cuiko
cuiko deleted the refactor/spm-layout branch May 22, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant